package com.konne.nightmare.FastPublicOpinion.mvp.model.impl;


import com.konne.nightmare.FastPublicOpinion.base.OnLoadDataListener;
import com.konne.nightmare.FastPublicOpinion.bean.CurrencyBean;
import com.konne.nightmare.FastPublicOpinion.bean.LoginBean;
import com.konne.nightmare.FastPublicOpinion.http.BaseObserver;
import com.konne.nightmare.FastPublicOpinion.http.BaseResponse;
import com.konne.nightmare.FastPublicOpinion.http.RetrofitFactory;
import com.konne.nightmare.FastPublicOpinion.mvp.model.ILoginActivityModel;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IMainActivityModel;

import org.json.JSONObject;


public class LoginActivityModelImpl implements ILoginActivityModel {
    @Override
    public void login(JSONObject requestBody, OnLoadDataListener<LoginBean.DataBean> onLoadDataListener) {
        RetrofitFactory.getLoginInstance().login(requestBody, new BaseObserver<LoginBean.DataBean>() {
            @Override
            protected void onSuccess(BaseResponse<LoginBean.DataBean> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void getPhoneActivationMsg(JSONObject requestBody, OnLoadDataListener<CurrencyBean> onLoadDataListener) {
        RetrofitFactory.getLoginInstance().getPhoneActivationMsg(requestBody, new BaseObserver<CurrencyBean>() {
            @Override
            protected void onSuccess(BaseResponse<CurrencyBean> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }
}
